package bean.control;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import eao.EaoProduct;
import entity.Product;
import entity.SocialNetwork;
import entity.UserSocialNetwork;

@ManagedBean(name="searchc")
@SessionScoped
public class SearchControl implements Serializable {
	private static final long serialVersionUID = 139077269494165440L;
	
	@EJB EaoProduct eaoProduct;

	private Product product;
	private List<Product> products;
	
	private String productId;
	
	private boolean edit;
	
	@PostConstruct
	public void init(){
		product = new Product();
	}
	
	public String search(){
		products = eaoProduct.search(product.getName());
		
		return "/system/results.xhtml?faces-redirect=true";  
	}
	
	public String view(Product p){
		this.product = p;

		return "/system/product.xhtml?faces-redirect=true";  
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public List<Product> getProducts() {
		return products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	public boolean isEdit() {
		return edit;
	}

	public void setEdit(boolean edit) {
		this.edit = edit;
	}
	
	
}
